﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Windows.Input;
//using System.ComponentModel;

//namespace Elentok.Common.Wpf.ViewModels.Dialogs
//{
//  /// <summary>
//  /// Defines the view model for the progress dialog
//  /// </summary>
//  public interface IProgressDialogViewModel : IDialogViewModel
//  {
//    /// <summary>
//    /// Gets or sets the message of the dialog
//    /// </summary>
//    string Message { get; set; }

//    /// <summary>
//    /// Gets or sets the progress (should be a value between 1.0 and 0.0)
//    /// </summary>
//    double Progress { get; set; }
//  }

//  /// <summary>
//  /// The view model for the progress dialog
//  /// </summary>
//  public class ProgressDialogViewModel : DialogViewModelBase, IProgressDialogViewModel
//  {
//    #region Fields

//    private string baseTitle = "Progress";
//    private string message;
//    private double progress;
//    private AsyncTask task;

//    #endregion

//    #region Ctor
//    /// <summary>
//    /// Initializes a new instance of the <see cref="ProgressDialogViewModel"/> class
//    /// </summary>
//    /// <param name="task"></param>
//    public ProgressDialogViewModel(AsyncTask task)
//    {
//      this.task = task;
//      this.baseTitle = task.Text;
//      this.Title = this.baseTitle;
      
//      task.ProgressChanged += new ProgressChangedEventHandler(Task_ProgressChanged);
//      task.Completed += new RunWorkerCompletedEventHandler(Task_Completed);
//    }

//    #endregion

//    #region Properties

//    /// <summary>
//    /// Gets or sets the message
//    /// </summary>
//    public string Message
//    {
//      get
//      {
//        return this.message;
//      }
//      set
//      {
//        if (this.message == value)
//          return;

//        this.message = value;
//        OnPropertyChanged("Message");
//      }
//    }

//    /// <summary>
//    /// Gets or sets the progress
//    /// </summary>
//    public double Progress
//    {
//      get
//      {
//        return this.progress;
//      }
//      set
//      {
//        if (this.progress == value)
//          return;

//        this.progress = value;
//        OnPropertyChanged("Progress");
//      }
//    }

//    #endregion

//    #region Event Handlers

//    private void Task_Completed(object sender, RunWorkerCompletedEventArgs e)
//    {
//      this.task.ProgressChanged -= Task_ProgressChanged;
//      this.task.Completed -= Task_Completed;
//      Close(true);
//    }

//    private void Task_ProgressChanged(object sender, ProgressChangedEventArgs e)
//    {
//      this.Progress = e.ProgressPercentage;
//      this.Message = e.UserState.ToString();
//    }

//    /// <summary>
//    /// This method is called when the dialog is shown to the user
//    /// </summary>
//    public override void OnShown()
//    {
//      base.OnShown();
//      task.InternalStartAsync();
//    }

//    #endregion
//  }
//}
